﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace ZQNB.Common.Attributes
{
    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
    public class NbAssemblyAttribute : Attribute
    {
        public NbAssemblyAttribute(string name)
        {
            Name = name;
        }
        public string Name { get; set; }
    }

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
    public class MenuAttribute : Attribute
    {
        public MenuAttribute()
        {

        }

        public MenuAttribute(string position, string module, string parentPk, string pk, string text, string href, string cssClass, double sortNum)
        {
            Text = text;
            Class = cssClass;
            Href = href;
            Module = module;
            Positon = position;
            SortNum = sortNum;
            Pk = pk;
            ParentPk = parentPk;
        }

        //模块和位置
        public string Module { get; set; }
        public string Positon { get; set; }

        //HrefSchema
        public string Href { get; set; }
        public double SortNum { get; set; }
        public string Text { get; set; }
        public string Class { get; set; }
        public string Pk { get; set; }
        public string ParentPk { get; set; }

        public static MenuAttribute CreateMenu(
            string position, string module, string parentPk, string pk, 
            string text, string href, string cssClass, double sortNum)
        {
            MenuAttribute menuAttribute = new MenuAttribute(
                position, module, parentPk, pk, text, href, cssClass, sortNum);
            return menuAttribute;
        }

        public static bool ValidateMenuTree(string position, IList<MenuAttribute> menuList)
        {
            return true;
        }

    }

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
    public class OpAttribute : Attribute
    {
        //模块和分类
        public string Module { get; set; }
        public string Category { get; set; }

        //HrefSchema
        public string Href { get; set; }
        public string Text { get; set; }
        public double SortNum { get; set; }
        public string ArgsName { get; set; }
        public string DefaultRoles { get; set; } //*,admin,member
        public bool CanEditDefaultRoles { get; set; } //是否可以编辑
        public string MenuPks { get; set; } //menuPk1,menuPk2
    }

    /// <summary>
    /// 软件协议模块标签，表示协议的元信息，作用在Assembly上
    /// area/controller/action
    /// eg: Space/*/*;Live/*/*;
    /// </summary>
    [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = true)]
    public class ModuleAttribute : Attribute
    {
        /// <summary>
        /// 模块的名称或ID
        /// </summary>
        public string ModuleName { get; set; }
        /// <summary>
        /// 模块的显示名称
        /// </summary>
        public string ModuleCaption { get; set; }
        /// <summary>
        /// 模块的收费控制点，可以是一个List，也可以一个用';'或','分割的字符串 //
        /// 其中每一个体格式为
        /// Area/Controller/Action
        /// 或者"Space/{controller}/{action};Portal/{controller}/{action};Space/{owner}/{controller}/{action};"
        /// </summary>
        public string ControlPoints { get; set; }
    }

    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
    public class NhibernateMapAttribute : Attribute
    {
    }

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class HasMetasInMethodAttribute : Attribute
    {
        public HasMetasInMethodAttribute()
        {
            ContainMethodMeta = true;
        }

        public bool ContainMethodMeta { get; set; }
    }
}
